import { ref, reactive,onMounted } from 'vue'
import axios from 'axios';

//https://dog.ceo/api/breeds/image/random Fetch!


export default function(){
    let dogs = reactive([
        'https://images.dog.ceo/breeds/terrier-norwich/n02094258_1703.jpg'
      ])
      
      onMounted(()=>{
        console.log('111');
          addDog()
      })
      
      async function addDog() {
        try {
          let result = await axios.get('https://dog.ceo/api/breeds/image/random')
          console.log(result);
          dogs.push(result.data.message)
        } catch (error) {
          // console.log(error)
          alert(error.message)
        }
      
      }
      //向外部提供东西
      return {dogs,addDog}
}